<?php
namespace app\api\controller;
use think\Controller;
use app\common\model\Client as ClientModel;

class Postclient extends Controller
{
    protected $client_model;

    public function _initialize(){
        parent::_initialize();
        $this->client_model = new ClientModel;
    }

    public function saveclientdata(){
        $data = $this->request->post();
        $validate_result = $this->validate($data,'Client');
        if($validate_result !== true){
            return json(['msg'=>$validate_result]);
        }else{
            $result = $this->client_model->allowField(true)->save($data);
            if($result){
                return json(['status'=>200,'msg'=>'保存成功']);
            }else{
                return json(['status'=>400,'msg'=>'保存失败']);
            }
        }
    }
}